import { ref, onMounted } from 'vue'
import { getSubCategoryAPI } from '@/apis/category'
import { useRoute } from 'vue-router'
export function usegetSubCategoryAPI() {
    const router = useRoute()
    //定义商品数据
    const subCategoryList = ref([])
    //定义需要的变量
    const subCategory = ref({
        categoryId: router.params.id,
        page: 1,
        pageSize: 10,
        sortField: 'publishTime'
    })
    const getSubCategory = async () => {
        const res = await getSubCategoryAPI(subCategory.value)
        subCategoryList.value = res.data.result.items
    }
    onMounted(() => {
        getSubCategory()
    })
    return {
        subCategoryList,
        subCategory,
        getSubCategory
    }
}